Is there ever a case when I should use delete[] when I have not used new[] to allocate memory?
Is there ever a case when I should use delete[] when I have not used new[] to allocate memory?
no..
i seem to have GCC 3.3.4
But how do i start it?
I dont have a menu for it or anything.
If osmeone else does the new[] for you?
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Could he mean if there is a new[] inside a conditional? At which point this might happen:
Code:int* ptr_var = 0; //... possibility of ptr_var = new int[SIZE] delete [] ptr_var;
I mean that or anything that you can think of.
Can you explain what you mean by "new[] inside a conditional"?
Whether the allocation was based on a condition. But that still means the delete has a corresponding new...Originally Posted by ChadJohnson
Well, just like delete, you can safely delete[] on a NULL pointer.Code:int main(void) { int* a = NULL; delete[] a; return 0; }
If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein